package com.atom.process.cnmuseum.bm.dao.process;


import java.util.List;

import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Repository;

import com.atom.common.dao.AvensCommonDao;
import com.atom.common.exception.AvensNullPointerException;
import com.atom.common.mb.entity.gl.GcxxDO;
import com.atom.common.remote.user.UserUtil;
import com.atom.process.cnmuseum.bm.entity.process.BmGcxxProcessDO;

@Repository
public class BmGcxxProcessDao extends AvensCommonDao<BmGcxxProcessDO> {
	public BmGcxxProcessDO findByProcessInstanceId(String processId) {
	    List<BmGcxxProcessDO> list = super.findByProperty("processId", processId);
	    if (list == null || list.size() == 0) {
	      throw new AvensNullPointerException("ProcessDO is null where processId = " + processId);
	    } else {
	      return list.get(0);
	    }
	  }
  
  
  public void createPDO(UserUtil user, String processInstanceId, GcxxDO gcxx) {
	  BmGcxxProcessDO pdo = new BmGcxxProcessDO();
	  BeanUtils.copyProperties(gcxx, pdo,"id");
	    pdo.setProcessId(processInstanceId);
	    super.save(pdo);
	  }

}
